From 97a265d1887df44d75cdb8403434f034eca2b2b7 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Mon, 12 Jul 2004 08:25:22 +0000 Subject: [PATCH] bitkeeper revision 1.1062.1.7 (40f24af2r5kZAs1cqmBvB4wRz47kpg) Fix the linker scripts to always produce exactly one loadable program segment. --- xen/arch/x86/boot/mkelf32.c | 14 +++++++++++++ xen/arch/x86/x86_32/xen.lds | 39 +++++++++++++++++++++---------------- xen/arch/x86/x86_64/xen.lds | 37 ++++++++++++++++++++--------------- 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/xen/arch/x86/boot/mkelf32.c b/xen/arch/x86/boot/mkelf32.c index 779dab662b..286a61315a 100644 --- a/xen/arch/x86/boot/mkelf32.c +++ b/xen/arch/x86/boot/mkelf32.c @@ -199,6 +199,13 @@ int main(int argc, char **argv) return 1; } + if ( in32_ehdr.e_phnum != 1 ) + { + fprintf(stderr, "Expect precisly 1 program header; found %d.\n", + (int)in32_ehdr.e_phnum); + return 1; + } + (void)lseek(infd, in32_ehdr.e_phoff, SEEK_SET); do_read(infd, &in32_phdr, sizeof(in32_phdr)); @@ -218,6 +225,13 @@ int main(int argc, char **argv) return 1; } + if ( in64_ehdr.e_phnum != 1 ) + { + fprintf(stderr, "Expect precisly 1 program header; found %d.\n", + (int)in64_ehdr.e_phnum); + return 1; + } + (void)lseek(infd, in64_ehdr.e_phoff, SEEK_SET); do_read(infd, &in64_phdr, sizeof(in64_phdr)); diff --git a/xen/arch/x86/x86_32/xen.lds b/xen/arch/x86/x86_32/xen.lds index 5947ebada5..bb9f327802 100644 --- a/xen/arch/x86/x86_32/xen.lds +++ b/xen/arch/x86/x86_32/xen.lds @@ -1,9 +1,14 @@ /* ld script to make i386 Linux kernel - * Written by Martin Mares ; + * Written by Martin Mares + * Modifified for i386 Xen by Keir Fraser */ OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") OUTPUT_ARCH(i386) ENTRY(start) +PHDRS +{ + text PT_LOAD ; +} SECTIONS { . = 0xFC400000 + 0x100000; @@ -12,61 +17,61 @@ SECTIONS *(.text) *(.fixup) *(.gnu.warning) - } = 0x9090 - .text.lock : { *(.text.lock) } /* out-of-line lock text */ + } :text =0x9090 + .text.lock : { *(.text.lock) } :text /* out-of-line lock text */ _etext = .; /* End of text section */ - .rodata : { *(.rodata) *(.rodata.*) } - .kstrtab : { *(.kstrtab) } + .rodata : { *(.rodata) *(.rodata.*) } :text + .kstrtab : { *(.kstrtab) } :text . = ALIGN(16); /* Exception table */ __start___ex_table = .; - __ex_table : { *(__ex_table) } + __ex_table : { *(__ex_table) } :text __stop___ex_table = .; __start___ksymtab = .; /* Kernel symbol table */ - __ksymtab : { *(__ksymtab) } + __ksymtab : { *(__ksymtab) } :text __stop___ksymtab = .; __start___kallsyms = .; /* All kernel symbols */ - __kallsyms : { *(__kallsyms) } + __kallsyms : { *(__kallsyms) } :text __stop___kallsyms = .; .data : { /* Data */ *(.data) CONSTRUCTORS - } + } :text _edata = .; /* End of data section */ . = ALIGN(8192); /* init_task */ - .data.init_task : { *(.data.init_task) } + .data.init_task : { *(.data.init_task) } :text . = ALIGN(4096); /* Init code and data */ __init_begin = .; - .text.init : { *(.text.init) } - .data.init : { *(.data.init) } + .text.init : { *(.text.init) } :text + .data.init : { *(.data.init) } :text . = ALIGN(16); __setup_start = .; - .setup.init : { *(.setup.init) } + .setup.init : { *(.setup.init) } :text __setup_end = .; __initcall_start = .; - .initcall.init : { *(.initcall.init) } + .initcall.init : { *(.initcall.init) } :text __initcall_end = .; . = ALIGN(4096); __init_end = .; . = ALIGN(4096); - .data.page_aligned : { *(.data.idt) } + .data.page_aligned : { *(.data.idt) } :text . = ALIGN(32); - .data.cacheline_aligned : { *(.data.cacheline_aligned) } + .data.cacheline_aligned : { *(.data.cacheline_aligned) } :text __bss_start = .; /* BSS */ .bss : { *(.bss) - } + } :text _end = . ; /* Sections to be discarded */ diff --git a/xen/arch/x86/x86_64/xen.lds b/xen/arch/x86/x86_64/xen.lds index d189a27e03..cdf1a6168e 100644 --- a/xen/arch/x86/x86_64/xen.lds +++ b/xen/arch/x86/x86_64/xen.lds @@ -1,7 +1,12 @@ /* Excerpts written by Martin Mares */ +/* Modified for x86-64 Xen by Keir Fraser */ OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") OUTPUT_ARCH(i386:x86-64) ENTRY(start) +PHDRS +{ + text PT_LOAD ; +} SECTIONS { . = 0xFFFF830000100000; @@ -10,61 +15,61 @@ SECTIONS *(.text) *(.fixup) *(.gnu.warning) - } = 0x9090 - .text.lock : { *(.text.lock) } /* out-of-line lock text */ + } :text = 0x9090 + .text.lock : { *(.text.lock) } :text /* out-of-line lock text */ _etext = .; /* End of text section */ - .rodata : { *(.rodata) *(.rodata.*) } - .kstrtab : { *(.kstrtab) } + .rodata : { *(.rodata) *(.rodata.*) } :text + .kstrtab : { *(.kstrtab) } :text . = ALIGN(16); /* Exception table */ __start___ex_table = .; - __ex_table : { *(__ex_table) } + __ex_table : { *(__ex_table) } :text __stop___ex_table = .; __start___ksymtab = .; /* Kernel symbol table */ - __ksymtab : { *(__ksymtab) } + __ksymtab : { *(__ksymtab) } :text __stop___ksymtab = .; __start___kallsyms = .; /* All kernel symbols */ - __kallsyms : { *(__kallsyms) } + __kallsyms : { *(__kallsyms) } :text __stop___kallsyms = .; .data : { /* Data */ *(.data) CONSTRUCTORS - } + } :text _edata = .; /* End of data section */ . = ALIGN(8192); /* init_task */ - .data.init_task : { *(.data.init_task) } + .data.init_task : { *(.data.init_task) } :text . = ALIGN(4096); /* Init code and data */ __init_begin = .; - .text.init : { *(.text.init) } - .data.init : { *(.data.init) } + .text.init : { *(.text.init) } :text + .data.init : { *(.data.init) } :text . = ALIGN(16); __setup_start = .; - .setup.init : { *(.setup.init) } + .setup.init : { *(.setup.init) } :text __setup_end = .; __initcall_start = .; - .initcall.init : { *(.initcall.init) } + .initcall.init : { *(.initcall.init) } :text __initcall_end = .; . = ALIGN(4096); __init_end = .; . = ALIGN(4096); - .data.page_aligned : { *(.data.idt) } + .data.page_aligned : { *(.data.idt) } :text . = ALIGN(32); - .data.cacheline_aligned : { *(.data.cacheline_aligned) } + .data.cacheline_aligned : { *(.data.cacheline_aligned) } :text __bss_start = .; /* BSS */ .bss : { *(.bss) - } + } :text _end = . ; /* Sections to be discarded */ -- 2.30.2